package com.chendx.store.user.controller;

import com.chendx.model.common.dtos.ResponseResult;
import com.chendx.model.user.UserInfoVo;
import com.chendx.model.user.dto.UserDto;
import com.chendx.store.api.user.UserControllerApi;
import com.chendx.store.user.service.UserService;
import com.chendx.store.user.service.UserSignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by chendx on 2022/4/21.
 */
@RestController
@RequestMapping("/api/user")
public class UserController implements UserControllerApi {

    @Autowired
    private UserService userService;
    @Autowired
    private UserSignService userSignService;

    @Override
    @GetMapping("/info")
    public ResponseResult loadUserInfo() {
        return userService.loadUserInfo();
    }

    @Override
    @GetMapping("/base")
    public ResponseResult loadBaseInfo() {
        return userService.loadBaseInfo();
    }

    @Override
    @GetMapping("/all")
    public ResponseResult loadAllInfo() {
        return userService.loadAllInfo();
    }


    @Override
    @GetMapping("/one")
    public UserInfoVo loadUser(String userId) {
        return userService.loadUser(userId);
    }

    @Override
    @GetMapping("/sign")
    public ResponseResult sign() {
        return userSignService.sgin();
    }

    @Override
    @GetMapping("/signInfo")
    public ResponseResult signInfo() {
        return userSignService.signInfo();
    }

    @Override
    @GetMapping("/decrScore")
    public ResponseResult decrScore() {
        return userSignService.decrScore();
    }

    @Override
    @GetMapping("/addScore")
    public ResponseResult addScore(Integer score) {
        return userSignService.addScore(score);
    }

    @Override
    @PostMapping("/update")
    public ResponseResult updateUser(@RequestBody UserDto dto) {
        return userService.updateInfo(dto);
    }


}
